package com.tengju.bff.interfaces.app.motivation;

import com.tengju.bff.interfaces.app.motivation.facade.UpgradeCenterFacade;
import com.tengju.bff.interfaces.app.motivation.vo.UpgradeDetailVO;
import com.tengju.bff.interfaces.shared.ApiResponse;
import com.tengju.bff.interfaces.shared.servlet.ServletContextUtil;
import com.tengju.bff.interfaces.shared.servlet.UserServletContext;
import com.tengju.user.domain.model.user.UserIdCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Validated
@Slf4j
@RestController
@Api(tags = "升级中心")
@RequestMapping(value = "/app/upgrade/center")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class UpgradeCenterController {

    private final UpgradeCenterFacade upgradeCenterFacade;

    @ApiOperation(value = "晋升中心", notes = "晋升中心")
    @RequestMapping(value = "detail", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<UpgradeDetailVO> upgradeDetail() {

        UserServletContext servletContext = ServletContextUtil.getServletContext();
        UserIdCode idCode = servletContext.needIdCode();
        return ApiResponse.newSuccess(upgradeCenterFacade
                .upgradeDetail(new com.tengju.data.domain.model.user.UserIdCode(idCode.getValue())));

//        return ApiResponse.newSuccess(new UpgradeDetailVO(
//                new StarLevelVO(20,"城市服务商2星"),
//                new StarLevelVO(30,"城市服务商3星"),
//                List.of(new UpgradeIndicatorVO("12","2","需直属经销商",true,"还差10人"),
//                        new UpgradeIndicatorVO("2","2","需培养服务商",true,"")),
//                "提示：最近更新时间 02.01 12:00，如果已满足城市服务商晋升条件，将在第2天邀约"
//        ));
    }
}
